﻿@using OA.Model.View;
@using OA.Model;
@using X.PagedList;
@using OA.Core.Helper;

@model PagedList<ApprovalItem>
@{
    CustomForm infoCustomForm = ViewBag.CustomForm;
    string title = "我的发起";
    ViewBag.Title = title;
    Layout = "~/Areas/Member/Views/Shared/_Layout.cshtml";
}
<div class="layui-tab layui-tab-brief" lay-filter="user">
    <div class="layui-form layui-tab-content" id="LAY_ucm">
        <form action="" class="layui-form">
            <div class="layui-form-item">
                <label class="layui-form-label" style="width: auto; padding-right: 5px;">主题：</label>
                <div class="layui-input-inline">
                    <input type="text" name="keyWord" class="layui-input" value="" />
                </div>
                <button type="button" class="layui-btn searchButton">搜索</button>
            </div>
        </form>
    </div>
    <table class="layui-table" lay-data="{url:'GetLaunchedData', cellMinWidth: 80, page: true,limit:15}" id="resultList" lay-filter="resultList">
        <thead>
            <tr>
                <th lay-data="{field:'No', width:100}">编号</th>
                <th lay-data="{field:'Name', width:120}">类型</th>
                <th lay-data="{field:'Title'}">主题</th>
                <th lay-data="{field:'StatusName', width:80}">状态</th>
                <th lay-data="{field:'Suspense', width:120}">当前审批人</th>
                <th lay-data="{field:'NeedExplainEmpID', width:120}">需沟通成员</th>
                <th lay-data="{field:'Explain', width:120}">解释说明</th>
                <th lay-data="{field:'CreateDateTime', width:160}">申请时间</th>
                <th lay-data="{field:'FinishTime', width:130}">到达时间</th>
                <th lay-data="{width:250, align:'center', toolbar: '#barDemo'}">操作</th>
            </tr>
        </thead>
    </table>
    <script type="text/html" id="barDemo">
        <a class="layui-btn layui-btn-xs" href="javascript:ShowPage('/Member/CustomForm/Show?customID={{d.CustomID}}&formID={{d.FormID}}','{{d.Title}}')">查看</a>
        <a class="layui-btn layui-btn-xs" lay-href="/Member/CustomForm/Show?customID={{d.CustomID}}&formID={{d.FormID}}&isPrint=true">打印</a>
        {{# if(d.Status==4){ }}
        <span class="layui-btn layui-btn-xs" lay-event="CarbonCopy" lay-data="{{d}}">抄送</span>
        {{# } }}
        {{# if(d.Status==1){ }}
        <a class="layui-btn layui-btn-xs" lay-event="revocation" lay-data="{{d}}">撤回</a>
        {{# } }}
    </script>
</div>
<script type="text/javascript">
    layui.use(['table', 'element'], function () {
        var table = layui.table;
        table.on('tool(resultList)', function (obj) {
            var data = obj.data;
            if (obj.event === 'CarbonCopy') {
                var url = "/Member/CustomForm/CarbonCopy/" + data.ID;
                layer.open({
                    type: 2,
                    title: '抄送',
                    shadeClose: true,
                    shade: false,
                    maxmin: false, //开启最大化最小化按钮
                    area: ['893px', '600px'],
                    content: url
                });
            }
            else if (obj.event === "revocation") {
                layer.confirm('请确认要撤回该审批单据吗？<p style="color:red;padding-top:12px;">单据号:' + data.No + '</p>', {
                    btn: ['确认撤回', '不小心点错了'], title: "审批撤回确认", area: ['400px', '200px'], //按钮
                },
                function () {
                    var url = "/Member/CustomForm/Revocation?id=" + data.ID;
                    $.getJSON(url, function (result) {
                        if (result.State == 200) {
                            layer.msg('审批撤回成功!');
                            $(".layui-laypage-btn")[0].click();
                        }
                        else {
                            layer.msg(data.Msg);
                            return;
                        }
                    });
                },
                function () {

                });
            }
        })
    })

    function CarbonCopyCallBack() {
        layer.closeAll();
        layer.msg("抄送成功");
    } 

</script>
